'''
第一版

s = "Hello, Python world!"
#第一题
print(len(s))
#第二题
count = s.count("o")
print({count})
#第三题
upper_s = s.upper()
print((upper_s))
#第四题
lower_s = s.lower()
print((lower_s))
#第五题
print(s.find("python"))
#第六题
new_s = s.replace("world","univers")
print(new_s)
#第七题
result = s.startswith("hello")
print(result)
#第八题
end = s.endswith("!")
print(end)
#第九题
m = s.split(",")
print(m)
#第十题
n = s.strip("!")
print(n)
#第十一题
reversed_s = s[::-1]
print(reversed_s)
#第十二题
python_str = s[s.find("Python"):s.find("Python") + len("Python")]
print({python_str})
#第十三题
removed_hello = s.replace("Hello,", "")
print({removed_hello})
#第十四题
concatenated_str = "Hello," + " World!"
print({concatenated_str})
#第十五题
merged_str = f"Year: {2021}"
print({merged_str})
#第十六题
first_a_index = s.find('a')
print({first_a_index})
#第十七题
last_e_index = s.rfind('e')
print({last_e_index})
#第十八题
space_count = s.count(" ")
print({space_count})
#第十九题
for char in s:
    print(char)
#第二十题
char_list = list(s)
print({char_list})
#第二十一题
sorted_list = sorted(list(s))
sorted_str = ''.join(sorted_list)
print({sorted_str})
#第二十二题
is_numeric = s.isnumeric()
print({is_numeric})
#第二十三题
joined_list = " ".join(['Hello,', 'Python', 'World!'])
print({joined_list})
#第二十四题
formatted_str = "Number: %d" % 100
print({formatted_str})
#第二十五提
is_lower = s.islower()
print({is_lower})
#第二十六题
is_upper = s.isupper()
print({is_upper})
#第二十七题
num_list = [1, 2, 3]
num_str = '-'.join(map(str, num_list))
print({num_str})
#第二十八题
o_positions = [i for i, char in enumerate(s) if char == 'o']
print({o_positions})
#第二十九题
first_replace = s.replace('o', 'O', 1)
print({first_replace})
#第三十题
insert_index = 7
new_str = s[:insert_index] + "amazing " + s[insert_index:]
print({new_str})
'''
'''
s ="python is great!"
#第一题
print(s[::-1])
#第二题
count = s.count('t')
print(count)
#第三题
new_s = s.replace("s","_")
print(new_s)
#第四题
import re
s2 = "A man, a plan, a canal, Panama!"
new_s2 = re.sub(r'[^a-zA-Z0-9]','',s2).lower()
hui = new_s2 ==new_s[::-1]
print(hui)
#第五题
w = s.find("is")
print(w)
#第六题
d = "_inserted"
t = s.find("t")
new_s = s[:t +1]+d+s[t +1:]
print(new_s)
#第七题
new_s = s.replace("great","awesome",1)
print(new_s)
#第八题
lengh = len(s)
mid = lengh//2
qian = s[:mid]
hou = s[mid:]
new_s = hou + qian
print(new_s)
#第九题
list = [n.capitalize() for n in s.strip()]
print(list)
#第十题
def encrypt(s):
    # 定义加密字典
    encryption_dict = {chr(97 + i): chr(109 + i % 13) for i in range(26)}
    encrypted_str = ""
    for char in s:
        if char in encryption_dict:
            encrypted_str += encryption_dict[char]
        else:
            encrypted_str += char
    return encrypted_str


s3 = "encryption"
encrypted_s3 = encrypt(s3)
print(f"加密后的字符串: {encrypted_s3}")
'''